package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile string //手机号
}

type UserIdentity struct {
	gorm.Model
	UserId   int64
	RealName string
	IdCard   string
	Status   int64
}

func (u *User) GetUserByMobile() error {
	return DB.Where("mobile=?", u.Mobile).Limit(1).Find(&u).Error
}

func (u *User) Register() error {
	return DB.Create(&u).Error
}

func (u *UserIdentity) CreateAuth() error {
	return DB.Create(&u).Error
}

func (u *UserIdentity) GetRealNameByUserId() error {
	return DB.Where("user_id=?", u.UserId).Limit(1).Find(&u).Error
}
